package org.moonlight.jvm.instructions.math.arithmetic.neg;

import org.moonlight.jvm.instructions.base.NoOperandsInstruction;
import org.moonlight.jvm.rtda.exclusive.Frame;
import org.moonlight.jvm.rtda.exclusive.OperandStack;

/**
 * INEG: 弹出 操作数栈 中 栈顶的 int变量，取负数，然后把结果推入操作数栈。
 *
 * @author Moonlight
 * @createTime 2023/8/16 18:02
 **/
public class INeg extends NoOperandsInstruction {

    @Override
    public void execute(Frame frame) {
        OperandStack operandStack = frame.getOperandStack();
        int val = operandStack.popInt();
        operandStack.pushInt( -val );
    }

}
